package com.china08.yxyapi.api.manage.tec.teaching.homework.worklist.workcorrect.upd1;

import java.text.ParseException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.api.YxyApiBaseController;
import com.china08.yxyapi.model.YxyApiRespModel;
import com.china08.yxyapi.service.manage.tec.teaching.homework.ElasticQuesService;

/**
 * 查看试题原题和解析
 */
@CrossOrigin
@RestController
public class Workcorrect1GetQues extends YxyApiBaseController {

    @Autowired
    ElasticQuesService elasticQuesService;

    @ResponseBody
    @RequestMapping(value = "/api_yw/manage/tec/teaching/homework/worklist/workcorrect1/ques/get", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public RespModel precess(//
            HttpServletRequest request, //
            HttpServletResponse response, //
            @RequestParam String quesId, //
            RespModel respModel) throws ParseException {
        try {
            respModel.ques = elasticQuesService.findByEsQuesId(quesId);
        } catch (Exception e) {
            respModel.ques = null;
        }
        return respModel;
    }

    /** 响应 **/
    public static class RespModel extends YxyApiRespModel {
        // 试题 Object
        public Object ques;
    }
}
